{include file="admintemplate/header.htm"}	
<script type="text/javascript">
$(document).ready(function(){
	var editor1;
	KindEditor.ready(function(K) {
			editor1 = K.create('textarea[name="articlecontent"]', {
			height:'900px',
			cssPath : './public/kindeditor/plugins/code/prettify.css',
			uploadJson : './public/kindeditor/php/upload_json.php',
			fileManagerJson : './public/kindeditor/php/file_manager_json.php',
			allowFileManager : true,
		});
		prettyPrint();
	});
	$("#addArticle").click(function(){
		$("#dis1").hide();
		$("#dis2").show();
		$.post("index.php?mod=article&act=getcolumns",
				function(data){
					var myjson='';
			        eval('myjson=' + data + ';');
			        var html='';
			        for(i=0;i<myjson.length;i++){
			        	html+="<option value='"+myjson[i]['column_id']+"'>———"+myjson[i]['column_name']+"———</option>";
			        }
					$("#column").html(html);
					var test = "{$columnid}";
					if(test == ""){
						$("#column option[value='{$columnpid}']").attr("selected","selected");
					} else {
						$("#column option[value='{$columnid}']").attr("selected","selected");
					}
		});
	});
	$("a[service='updateArticle']").click(function(){
// 		alert($("#editarticle").val());
		$("#dis1").hide();
		$("#dis2").show();
		$("#formtitle").html("修改文章");
		$("#uparticle-btn").attr("value", "修改");
		$("#formcontent").attr("action", "index.php?mod=article&act=modifyarticle&articleid=" + $(this).attr("id"));
		$.post("index.php?mod=article&act=getcolumns",
			function(data){
				var myjson='';
		        eval('myjson=' + data + ';');
		        var html='';
		        for(i=0;i<myjson.length;i++){
		        	html+="<option value='"+myjson[i]['column_id']+"'>———"+myjson[i]['column_name']+"———</option>";
		        }
				$("#column").html(html);
		});
		$.post("index.php?mod=article&act=updateArticle&articleid=" + $(this).attr("id"),
				function(data){
					var myjson='';
			        eval('myjson=' + data + ';');
					$("#title").val(myjson['article_title']);
					var columnid = myjson['column_id'];
					$("#column option[value='"+columnid+"']").attr("selected","selected");
					$("#article_pic").attr("src", myjson['article_picture']);
					$("#introduce").val(myjson['article_introduction']);
					editor1.html(myjson['article_content']);
					
		});
	});
	$("a[service='deleteArticle']").click(function(){
		var id = $(this).attr("id");
		alertify.confirm("你确定要删除吗?",function(e){
			if(e) {
				$.post("index.php?mod=article&act=deleteArticle&articleid=" + id ,
					function(data){
						if($.trim(data) == "删除成功"){
							alertify.success(data);
							setTimeout('location.href=location.href',1000);
						}else{
							alertify.error(data);
						}
				});
			}
		});
	});
	$("#reset").click(function(){
		alertify.confirm("你确定要返回吗?",function(e){
			if(e) {
				location.href=location.href;
			}
		});
	});
});	
	
</script>
<script type="text/javascript"  src="./public/js/checkjs/uploadarticle.js"></script>
<div class="main" style="margin-top: 3px">
<div class="twovar {if in_array($mod,array('shippingAddress2'))}nothing-twovar{/if}" >
  <ul>
  		{foreach $lcolumnlist as $key => $column}
			<li><a style="border-color: gray; font-size:15px;" href="index.php?mod=article&act=getArticle&columnid={$column.column_id}" {if $columnid== {$column.column_id} }class = "cho"{/if}>{$column.column_name}</a></li>
		{/foreach}
		<li><a id="checkArticle" style="border-color: gray;  font-size:15px;" href="index.php?mod=article&act=getCheckArticle&columnpid={$columnpid}" {if $smarty.get.act == 'getCheckArticle'}class = "cho"{/if}>未审核文章</a></li>
  </ul>
</div>
<div id="dis1">
<table cellspacing="0" width="100%">
   <thead class="title">
		<tr>
			<th>作者</th>
			<th>图片</th>
			<th>标题</th>
			<th>添加时间</th>
			<th>导语</th>
			<th>访问数</th>
			<th>赞/踩数</th>
			<th>评论数</th>
			<th colspan="3">操作</th>
			<th><a id="addArticle" href="javascript:void(0)" style="color:blue">添加文章</a></th>
		</tr>
	<thead>
		<tbody>
			{foreach $newslist as $key=>$newsinfo}
				<tr id="del{$newsinfo.article_id}">
					<td>{$newsinfo.article_author}</td>
					<td><img src={$newsinfo.article_picture} width="40px" height="32px"></td>
					<td style="width:120px">{$newsinfo.article_title}</td>
					<td>{date("Y-m-d H:i:s",$newsinfo.article_addtime)}</td>
					<td style="width:180px">{$newsinfo.article_introduction}</td>
	 				<td>{$newsinfo.article_views}</td>
					<td>{$newsinfo.article_agree}/{$newsinfo.article_disagree}</td>		
					<td>{$newsinfo.article_comments}</td>
					<td colspan="3">
						<a href="javascript:void(0)" id="{$newsinfo.article_id}" service="updateArticle"><img src='../public/img/icn_edit.png' title="编辑"><input id="editarticle" type="hidden" value="{$newsinfo.article_id}" /></a>
						<a href="javascript:void(0)" id="{$newsinfo.article_id}" service="deleteArticle"><img src='../public/img/icn_trash.png' title="删除 "></a>
						<a href="index.php?mod=count&act=index&article_id={$newsinfo.article_id}" id="countArticle"><img src='../public/img/logisticle.png' title="统计"></a>
					</td>
					<td></td>
				</tr>
			{/foreach}
		</tbody>
</table>
<div class="bottomvar">
		<div class="pagination">{$pageStr}</div>
	</div>
</div>
</div>
<div id="dis2" class="div_form" style="display:none; width:800px" >
			<form id="formcontent" method="post" action="index.php?mod=article&act=addarticle" enctype="multipart/form-data">
					<div class = "my_comment" id="formtitle">投递文章</div>
					<div class="uinArea">
						<label class="input-tips">标题：</label>
						<input class = "inputOuter" style="width:500px; type = "text" id="title"  name="articletitle"/>
					</div>
					<div class="uinArea">
						<label class="input-tips">栏目：</label>
							<select class="inputOuter" style="height:35px;width:180px;" id="column" name="columnid">
							</select>
					</div>
					<div class="uinArea">
						<label class="input-tips">图片：</label>
						<input class = "inputOuter" style="margin-top:20px;" type = "file" id="picture" name="articlepicture" multiple="multiple">
						<!-- <span><input class = "my_a_button" type="button" value="浏览"></span> -->
					</div>
					<div class = "show_pic">
						<img class="my_picture" src="" style="width:160px;height:120px;" id="article_pic"/>
					</div>
					<div class="uinArea">
						<label class="input-tips">导语：</label>
						<textarea  class="inputOuter" style="height: 80px;width:500px;"  id="introduce" name="articleintroduction"></textarea>
					</div>
					<div class="line">
						<div class="my_comment">内&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;容</div>
						<div style="margin-left: 76px;">
							<textarea name="articlecontent" style="width:500px;height:200px;" id="content" ></textarea>
						</div>
					</div>
					<div class="all_btn" style="margin-left: 280px;">
						<input class = "button_blue" type = "submit" value = "投递" id="uparticle-btn"/>
						<input class = "button_blue" type = "reset" value = "取消" id="reset"/>
					</div>
					</form>
			</div>
{include file="admintemplate/footer.htm"}
